const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    url:'http://img5.feijiu.net/video/shop/2021/03/09/14092653590376.mp4',
    false:false,
    desc:'',
    tit:'',
    titnum:0,
    descnum:0,
    duration:25,
    type:1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      url:app.data.vodurl+options.url,
      duration:options.duration,
      type:options.type
    })
    // console.log(this.data)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.videoContext = wx.createVideoContext('myVideo');
  },
  descinput:function (e) {
    if (e.detail.value.length > 100) {
      app.tishi('最多100个字哦!');return false
    }
    this.setData({
      desc:e.detail.value,
      descnum:e.detail.value.length
    })
  },
  titinput:function (e) {
    if (e.detail.value.length > 100) {
      app.tishi('最多48个字哦!');return false
    }
    this.setData({
      tit:e.detail.value,
      titnum:e.detail.value.length
    })
  },  
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  tijiao:function () {
    var FjLoginLog = wx.getStorageSync('FjLoginLog'); 
    if (this.data.titnum < 2) {
      app.tishi('请输入2-48字的标题!');return false
    }
    var api_input = {
      LoginUID:FjLoginLog.UID,
      ID:0,
      Type:this.data.type,
      Video:this.data.url,
      VideoDuration:this.data.duration,
      Title:this.data.tit,
      Intro:this.data.desc
    }
    console.log(api_input)
    app.getDaoPost('api/FeijiuApp/Feijiu_Add_UserVideo',api_input,function (r) {
      console.log(r)
      if (r.code == 200) {
        app.tishi('添加成功!');
        setTimeout(function () {
          wx.navigateBack()
        },1000)
      }else{
        app.tishi(r.message);
      }
    })
  }
})